package cn.itcast.goods.pager;

import java.util.List;

/**
 * 分页bean，它会在各层之间传递数据
 * @author GiantTao
 *
 * @param <T>
 */
public class PageBean<T> {
	private int pc;//pageCode当前页码
	private int tr;//总记录数
	private int ps;//每页记录数
	private String url;//请求路径和参数，例如：/BookServlet?method=findXXX&cid=1&bname=2
	private List<T> beanList;
	//获取总页数，该方法没有对应的变量，因为是通过其他变量计算得出的，因而只需要提供一个get方法即可
	public int getTp(){
		int tp=tr/ps;
		return tr%ps == 0 ? tp: tp+1;
	}
	public int getPc() {
		return pc;
	}
	public void setPc(int pc) {
		this.pc = pc;
	}
	public int getTr() {
		return tr;
	}
	public void setTr(int tr) {
		this.tr = tr;
	}
	public int getPs() {
		return ps;
	}
	public void setPs(int ps) {
		this.ps = ps;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public PageBean(int pc, int tr, int ps, String url, List<T> beanList) {
		super();
		this.pc = pc;
		this.tr = tr;
		this.ps = ps;
		this.url = url;
		this.beanList = beanList;
	}
	public List<T> getBeanList() {
		return beanList;
	}
	public void setBeanList(List<T> beanList) {
		this.beanList = beanList;
	}
	public PageBean() {
		super();
		// TODO Auto-generated constructor stub
	}
	
}
